package cn.easyproject.easyee.sm.cmsmoudle.service.impl;

import java.util.List;
import java.io.Serializable;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cn.easyproject.easyee.sm.cmsmoudle.criteria.MenuCriteria;
import cn.easyproject.easyee.sm.cmsmoudle.entity.Menu;
import cn.easyproject.easyee.sm.cmsmoudle.dao.MenuDAO;
import cn.easyproject.easyee.sm.cmsmoudle.service.MenuService;
import cn.easyproject.easyee.sm.base.service.BaseService;
import cn.easyproject.easyee.sm.base.pagination.PageBean;

/**
 * Menu Service, generated by EasyAuto
 * Must extends BaseService
 * 
 * @author easyproject.cn
 * @version 1.0
 *
 * 
 */
@Service("menuService")
public class MenuServiceImpl extends BaseService implements MenuService {

		
	@Resource
	MenuDAO menuDAO;

	@Override
	public void save(Menu menu) {
		menuDAO.save(menu);
	}

	@Override
	public void delete(Serializable id) {
		menuDAO.delete(id);
	}
	@Override
	public void delete(String[] values) {
		menuDAO.deleteByIds(values);
	}
	
	@Override
	public void update(Menu o) {
		menuDAO.update(o);
	}

	@Override
	public Menu get(Serializable id) {
		return menuDAO.get(id);
	}

	@Override
	@SuppressWarnings("rawtypes")
	public void findByPage(PageBean pageBean, MenuCriteria menuCriteria) {
		pageBean.setFrom(" web_menu ");
		pageBean.setSelect("*");
		pageBean.setEasyCriteria(menuCriteria);
		
		// pagination
		menuDAO.pagination(pageBean);
	}

	@Override
	public int findMaxRow() {
		return menuDAO.findMaxRow();
	}
	
	@Override
	public int findMaxPage(int rowPerPage) {
		return (menuDAO.findMaxRow()-1)/rowPerPage+1;
	}

	@Override
	@SuppressWarnings("unchecked")
	public List<Menu> findAll(){
		return menuDAO.findAll();
	}

}
